<?php
/**
 * 上报统计信息
 * Created by PhpStorm.
 * User: denh
 * Date: 17/2/6
 * Time: 下午4:58
 */
namespace bs;

use tools\redis;

include_once _LHDir . 'tools/tools.redis.php';
class BsStatistics extends \Base {

    private static $hproseHttpClient;

    function __construct() {
        $this->load_hprose();
    }

    function load_hprose($base_url = STATISTICS_URL) {
        require_once _LHDir . 'sdk/hprose-php-master/src/Hprose.php';
        self::$hproseHttpClient = new \HproseHttpClient($base_url);
    }
    /**
     * 上报日活跃用户
     */
    function activeUser($openId) {
        $redis = redis::instance();
        if (!$redis->get($openId)) {
            $redis->set($openId, $openId, $redis->residueTime());

            $doUser = new \Do用户();
            $doDoctor = new \Do医师详情();
            $doUser->set_openID($openId);
            $doUser->loadFromDB();
            $doDoctor->set_用户id($doUser->get_id());
            $doDoctor->loadFromDB();

            self::$hproseHttpClient->CourseController_userInfo(
                $doUser->get_userCenterID() ? $doUser->get_userCenterID() : $openId,
                $doUser->get_telephone(),
                $doUser->get_name(),
                $doDoctor->get_医院(),
                $doDoctor->get_职务(),
                $doDoctor->get_专业领域(),
                '',
                '',
                $doUser->get_province(),
                $doUser->get_city(),
                1,
                102
            );
        }
    }

    function newUser($openId, $name) {
        self::$hproseHttpClient->CourseController_userInfo(
            $openId,
            '',
            $name,
            '',
            '',
            '',
            '',
            '',
            '',
            '',
            1,
            100
        );
    }
}